<script setup lang="ts">
import type { AnalysisOverviewItem } from '../typing';

import {
  Card,
  CardContent,
  CardFooter,
  CardHeader,
  CardTitle,
  VbenCountToAnimator,
  VbenIcon,
} from '@vben-core/shadcn-ui';

interface Props {
  items?: AnalysisOverviewItem[];
}

defineOptions({
  name: 'AnalysisOverview',
});

withDefaults(defineProps<Props>(), {
  items: () => [],
});
</script>

<template>
  <div
    class="grid h-full grid-cols-1 place-items-center gap-4 md:grid-cols-2 lg:grid-cols-3"
  >
    <template v-for="item in items" :key="item.title">
      <Card :title="item.title" class="mx-auto w-full max-w-xs">
        <CardHeader class="text-center">
          <CardTitle class="text-xl">{{ item.title }}</CardTitle>
        </CardHeader>

        <CardContent
          class="flex flex-col items-center justify-center space-y-2"
        >
          <VbenCountToAnimator
            :end-val="item.value"
            :start-val="1"
            class="text-2xl"
            prefix=""
          />
          <VbenIcon :icon="item.icon" class="size-8" />
        </CardContent>

        <CardFooter class="flex flex-col items-center justify-center space-y-1">
          <span>{{ item.totalTitle }}</span>
          <VbenCountToAnimator
            :end-val="item.totalValue"
            :start-val="1"
            prefix=""
          />
        </CardFooter>
      </Card>
    </template>
  </div>
</template>
